//
//  WPUserAccount.m
//  wobingwoyi
//
//  Created by WGP on 16/8/9.
//  Copyright © 2016年 WGP. All rights reserved.
//

#import "WPUserAccount.h"

@implementation WPUserAccount

+(instancetype)userAccountWithDict:(NSDictionary *)dict
{
    id obj= [[self alloc] init];
    [obj setValuesForKeysWithDictionary:dict];
    return obj;
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{
    [aCoder encodeObject:_user forKey:@"user"];
    [aCoder encodeObject:_token forKey:@"token"];

}
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
    if(self = [super init])
    {
        _user = [aDecoder decodeObjectForKey:@"user"];
        _token = [aDecoder decodeObjectForKey:@"token"];

    }
    return self;
}

//归结当方法
-(void)saveUserAccount
{
    [NSKeyedArchiver archiveRootObject:self toFile:filepath];

}

-(instancetype)loadUserAccount
{
    return  [NSKeyedUnarchiver unarchiveObjectWithFile:filepath];
}

@end
